package com.wzy.service.reposirory.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.wzy.common.base.result.R;
import com.wzy.service.reposirory.entity.UserSentence;
import com.wzy.service.reposirory.service.UserSentenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wuzhengyu
 * @since 2021-03-13
 */
@RestController
@RequestMapping("/user-sentence")
public class UserSentenceController {

    @Autowired
    UserSentenceService userSentenceService;

    /**
     * 获取指定文章的所有句子
     * @param uid
     * @param uaid
     * @return
     */
    @GetMapping("/sentences")
    public R getSentenceByUidAndAid(String uid, String uaid) {
        List<UserSentence> list = userSentenceService.list(Wrappers.<UserSentence>lambdaQuery()
                .eq(UserSentence::getUid, uid)
                .eq(UserSentence::getUserArticleId, uaid));
        return R.ok().data("sentences", list);
    }

}

